package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import com.huawei.appgallery.productpurchase.api.ProductDetailBean;
import com.huawei.appgallery.productpurchase.impl.cache.DpsProductDetail;
import com.huawei.appgallery.productpurchase.ui.widget.dldbtn.ProductPurchaseDldButton;
import com.huawei.hms.framework.common.ContainerUtils;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import com.huawei.hms.support.api.entity.pay.HwPayConstant;
import java.lang.ref.WeakReference;

public class crr {

    static class a implements cks {
        private WeakReference<Context> ˊ;
        private WeakReference<CheckBox> ˋ;
        private DpsProductDetail ˎ;
        private ProductDetailBean ˏ;
        private int ॱ;

        a(Context context, CheckBox checkBox, ProductDetailBean productDetailBean, DpsProductDetail dpsProductDetail, int i) {
            this.ˊ = new WeakReference(context);
            this.ˋ = new WeakReference(checkBox);
            this.ˏ = productDetailBean;
            this.ˎ = dpsProductDetail;
            this.ॱ = i;
        }

        public void enableNetworking() {
            Context context = (Context) this.ˊ.get();
            CheckBox checkBox = (CheckBox) this.ˋ.get();
            if (checkBox != null) {
                csr.ˎ(!checkBox.isChecked());
            }
            if (context != null) {
                crr.ˎ(context, this.ˏ, this.ˎ, this.ॱ);
            } else {
                cro.ˏ().ˏ(2);
            }
        }

        public void upgrade() {
            cro.ˏ().ˏ(3);
        }

        public void ˋ() {
        }
    }

    static class b implements cks {
        private ProductDetailBean ˎ;
        private WeakReference<Context> ˏ;
        private cke ॱ;

        public b(Context context, ProductDetailBean productDetailBean, cke o_cke) {
            this.ˏ = new WeakReference(context);
            this.ˎ = productDetailBean;
            this.ॱ = o_cke;
        }

        public void enableNetworking() {
            Context context = (Context) this.ˏ.get();
            if (context != null) {
                csi.ˋ(this.ˎ.ॱـ());
                new csj(context).ˋ(new ProductPurchaseDldButton(context), this.ˎ, this.ॱ);
            }
            crf.ˎ.ˋ("DeepLinkJumpUtils", "install third app");
            cro.ˏ().ˏ(8);
        }

        public void upgrade() {
            cro.ˏ().ˏ(3);
        }

        public void ˋ() {
        }
    }

    public static void ˎ(Context context, ProductDetailBean productDetailBean, int i, int i2, int i3) {
        cku ˏ = cku.ˏ(context, cku.class, null, context.getResources().getString(i, new Object[]{productDetailBean.v_()}));
        ˏ.ॱ(-1, context.getResources().getString(i2));
        switch (i3) {
            case -2:
                csi.ˏ("NOINSTALLED");
                csi.ˋ(10);
                ˏ.ॱ(new b(context, productDetailBean, cke.ˋ));
                break;
            case 1:
                csi.ˏ("NOINSTALLED");
                csi.ˋ(10);
                ˏ.ॱ(new b(context, productDetailBean, cke.ˏ));
                break;
            case 3:
                csi.ˏ("LOWVERSION");
                csi.ˋ(6);
                ˏ.ॱ(new b(context, productDetailBean, cke.ᐝ));
                break;
            case 4:
                csi.ˏ("LOWVERSION");
                csi.ˋ(6);
                ˏ.ॱ(new b(context, productDetailBean, cke.ʽ));
                break;
            default:
                ˏ.ॱ(new b(context, productDetailBean, cke.ˊ));
                break;
        }
        ˏ.ˋ(context, productDetailBean.ॱـ());
    }

    public static void ˎ(Context context, ProductDetailBean productDetailBean, int i, int i2) {
        csi.ˏ("ILLEGAL");
        csi.ˋ(15);
        cku ˏ = cku.ˏ(context, cku.class, null, context.getResources().getString(i, new Object[]{productDetailBean.v_(), cso.ˋ(context)}));
        ˏ.ॱ(-1, context.getResources().getString(i2));
        ˏ.ॱ(new b(context, productDetailBean, cke.ˊˊ));
        ˏ.ˋ(context, productDetailBean.ॱـ());
    }

    public static void ˊ(Context context, ProductDetailBean productDetailBean, DpsProductDetail dpsProductDetail, int i) {
        cku ˏ = cku.ˏ(context, cku.class, null, null);
        View inflate = LayoutInflater.from(context).inflate(crh$e.ˋ, null);
        CheckBox checkBox = (CheckBox) inflate.findViewById(crh$d.ˎ);
        ((TextView) inflate.findViewById(crh$d.ˊ)).setText(context.getResources().getString(o.crh.b.ͺ, new Object[]{cso.ˋ(context), productDetailBean.v_()}));
        checkBox.setText(context.getResources().getString(o.crh.b.ʾ));
        int ˎ = ewb.ˎ((Activity) inflate.getContext());
        inflate.setPadding(ˎ, ˎ, ˎ, 0);
        ˏ.ˊ(inflate);
        ˏ.ॱ(-1, context.getResources().getString(o.crh.b.ᐝॱ));
        ˏ.ॱ(new a(context, checkBox, productDetailBean, dpsProductDetail, i));
        ˏ.ˋ(context, productDetailBean.ॱ());
    }

    public static void ˎ(Context context, ProductDetailBean productDetailBean, DpsProductDetail dpsProductDetail, int i) {
        try {
            crf.ˎ.ˋ("DeepLinkJumpUtils", "Jump to the third app.");
            if (productDetailBean == null || dpsProductDetail == null) {
                cro.ˏ().ˏ(2);
                return;
            }
            String ˎ = ˎ(productDetailBean, dpsProductDetail);
            csi.ˊ(ˎ);
            if (cso.ॱ(ˎ, productDetailBean.ॱـ())) {
                Intent intent = new Intent();
                intent.setAction(ACTION.HWID_SCHEME_URL);
                intent.setData(Uri.parse(ˎ));
                intent.setFlags(268435456);
                intent.setPackage(productDetailBean.ॱـ());
                context.startActivity(intent);
                cro.ˏ().ˏ(8);
                return;
            }
            crf.ˎ.ˏ("DeepLinkJumpUtils", "Url is illegal. url=" + productDetailBean.ˊ());
            cso.ˎ(context, o.crh.b.ॱˋ, productDetailBean.v_());
            cro.ˏ().ˏ(2);
        } catch (Exception e) {
            crf.ˎ.ˏ("DeepLinkJumpUtils", e.toString());
            if (productDetailBean != null) {
                ˏ(context, productDetailBean.v_(), i);
            } else {
                cro.ˏ().ˏ(1);
            }
        }
    }

    private static void ˏ(Context context, String str, int i) {
        if (cso.ˏ(i)) {
            cso.ˎ(context, o.crh.b.ʻॱ, str);
        } else {
            cso.ˎ(context, o.crh.b.ॱˋ, str);
        }
        cro.ˏ().ˏ(2);
    }

    private static String ˎ(ProductDetailBean productDetailBean, DpsProductDetail dpsProductDetail) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(productDetailBean.ˊ());
        if (productDetailBean.ˊ().contains("?")) {
            stringBuilder.append(ContainerUtils.FIELD_DELIMITER);
        } else {
            stringBuilder.append("?");
        }
        stringBuilder.append(HwPayConstant.KEY_PRODUCT_NO).append(ContainerUtils.KEY_VALUE_DELIMITER).append(dpsProductDetail.ॱ()).append(ContainerUtils.FIELD_DELIMITER).append(HwPayConstant.KEY_COUNTRY).append(ContainerUtils.KEY_VALUE_DELIMITER).append(cdn.ˏ()).append(ContainerUtils.FIELD_DELIMITER).append(HwPayConstant.KEY_CURRENCY).append(ContainerUtils.KEY_VALUE_DELIMITER).append(dpsProductDetail.ˏ()).append(ContainerUtils.FIELD_DELIMITER).append("price").append(ContainerUtils.KEY_VALUE_DELIMITER).append(dpsProductDetail.ˊ());
        if (dpsProductDetail.ॱॱ() != null) {
            stringBuilder.append(ContainerUtils.FIELD_DELIMITER).append("promPrice").append(ContainerUtils.KEY_VALUE_DELIMITER).append(dpsProductDetail.ॱॱ().ˋ()).append(ContainerUtils.FIELD_DELIMITER).append("promStartDate").append(ContainerUtils.KEY_VALUE_DELIMITER).append(dpsProductDetail.ॱॱ().ॱ()).append(ContainerUtils.FIELD_DELIMITER).append("promEndDate").append(ContainerUtils.KEY_VALUE_DELIMITER).append(dpsProductDetail.ॱॱ().ˎ());
        }
        stringBuilder.append(ContainerUtils.FIELD_DELIMITER).append(HwPayConstant.KEY_SIGN).append(ContainerUtils.KEY_VALUE_DELIMITER).append(dof.ˎ(dpsProductDetail.ʻ()));
        return stringBuilder.toString();
    }
}
